#pragma once
#include "log/channel.hpp"
#include "log/message.hpp"
#include "event/mutex.hpp"
using JHCPP::event::CMutex;
#include <string>

namespace JHCPP
{
	namespace log
	{
		/*Windows only*/
		class CEventLogChannel : public CChannel
		{
		public:
			CEventLogChannel();
			CEventLogChannel(const std::string& name);
			CEventLogChannel(const std::string& name, const std::string& host);

			void open();
			void close();

			void log(const CMessage& msg);

			void setProperty(const std::string& name, const std::string& value);
			std::string getProperty(const std::string& name) const;

			static const std::string PROP_NAME;
			static const std::string PROP_HOST;
			static const std::string PROP_LOGHOST;
			static const std::string PROP_LOGFILE;

		protected:
			~CEventLogChannel();
			static int getType(const CMessage& msg);
			static int getCategory(const CMessage& msg);
			void setUpRegistry() const;

			static std::string findLibrary(const char* name);

		private:
			std::string m_name;
			std::string m_host;
			std::string m_logFile;
			HANDLE      m_h;
		};
	}//end of namespace log
}//end of namespace JHCPP
